var Page = function(){
    this.init();
};
Page.prototype = {
    params: {
        passport: '',
        userId:'',
        listRows: 10,
        total: 0,
        page:1,
        returnTotal: 0,
        returnPage:1,
        proTotal: 0,
        proPage:1,
        paypage:1,
        payTotal:0,
        fipage:1,
        fitotal:0,
        messagepage:1,
        messageTotal:0,
        busipage:1,
        busiTotal:0,
        isVip:'',
        annualFee:'',
        loanSn:'',
        title:'',
        gmtStart:'',
        gmtEnd:'',
        returngmtStart:'',
        returngmtEnd:'',
        busigmtStart:'',
        busigmtEnd:'',
        progmtStart:'',
        progmtEnd:'',
        state:'',
        orderType:'',
        orderNumber:'',
        withdrawNumber:'',
        moneyStart:'',
        moneyEnd:'',
        financeState:'',
        busititle:'',
        order:'desc'
    },
    init: function(){
        this.initParams();
        this.initEvent();
    },
    initParams: function(){
        this.params.passport = Pub.getCookie('_PASSPORT');
        this.params.userId = Pub.getSession('userId');
    },
    getData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            userId:parseInt(_this.params.userId),
        };
        console.log(paramsObj);
        Api.userlistdetails(paramsObj, function(data){
            console.log(data);
            var data=data[0];
            $('#mobile').text(data.mobile);
            $('#userId').text(data.userId);
            $('#gmtCreate').text(data.gmtCreate);
            $('#realName').text(data.realName || '~');
            $('#eachDistrict').text(data.eachDistrict);

            if (data.sex==1) {
                $('#sex').text('男');
            }else if(data.sex==2){
                $('#sex').text('女');
            }else{
                $('#sex').text('未知');
            };
            if (data.headPortrait!='') {
                $('#headImg').attr('src', data.headPortrait);
            };
            if (data.isVip==1) {
                $('#isVip').text('会员');
            }else{
                $('#isVip').text('非会员');
            };
            $('#referees').text(data.referees);
            $('#orderSumBorrowing').text('￥'+data.orderSumBorrowing);
            $('#teamTotalNum').text(data.teamTotalNum);
            $('#teamVipTotalNum').text(data.teamVipTotalNum);
            $('#billTotalMoney').text('￥'+data.billTotalMoney);
            $('#outstanding').text('￥'+data.outstanding);
            $('#overdue').text('￥'+data.overdue);
            $('#combination').text('￥'+data.combination);

            $('#real_name').text(data.realName || '~');
            $('#idNumber').text(data.realNameCertification.idNumber || '~');
            $('#idValidity').text(data.realNameCertification.startTerm+'~'+data.realNameCertification.endTerm);

            if (data.realNameCertification.idcardFront) {
                $('#idcardFront').html('<img src="'+data.realNameCertification.idcardFront+'" >');
            };
            if (data.realNameCertification.idcardBack) {
                $('#idcardBack').html('<img src="'+data.realNameCertification.idcardBack+'" >');
            };

            _this.getBankList(data.bankcard);
        });
    },
    getBankList:function(data){
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html += '<tr>'+
                            '<td class="text-c">'+data[i].bankName+'</td>'+
                            '<td class="text-c">'+data[i].cardNumber+'</td>'+
                            '<td class="text-c">'+data[i].bankAddress+'</td>'+
                        '</tr>';
            }
            $('#bankList').html(html);
        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="3" >暂无数据</td>' +
                '</tr>';
            $('#bankList').html(html);

        }
    },
    getTeamData:function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            page: _this.params.page,
            listRows: _this.params.listRows,
            userId:_this.params.userId,
            gmtEnd:_this.params.gmtEnd,
            gmtStart:_this.params.gmtStart,
            mobile: _this.params.mobile,
            isVip: _this.params.isVip,
            order:_this.params.order,
            annualFee:_this.params.annualFee
        };
        console.log(paramsObj);
        Api.teammemberslist(paramsObj, function(data) {
            console.log(data);
            _this.getTeamList(data.list);
            _this.params.total = data.totalPages;
            layui.use('laypage', function() {
                var laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'teamPage',
                    index: 1,
                    theme: '#3498db',
                    curr: _this.params.page,
                    count: _this.params.total, //数据总数，从服务端得到
                    hash: 'curr_page',
                    layout: ['prev', 'page', 'next', 'skip'],
                    jump: function(obj, first) {
                        _this.params.page = obj.curr;
                        //obj包含了当前分页的所有参数，比如：curr当前页
                        var Params = {
                            passport: _this.params.passport,
                            page: _this.params.page,
                            listRows: _this.params.listRows,
                            userId:_this.params.userId,
                            gmtEnd:_this.params.gmtEnd,
                            gmtStart:_this.params.gmtStart,
                            mobile: _this.params.mobile,
                            isVip: _this.params.isVip,
                            order:_this.params.order,
                            annualFee:_this.params.annualFee
                        };
                        Api.teammemberslist(Params, function(data) {
                            _this.getTeamList(data.list);

                        })
                    }
                });
            });
        });
    },
    getTeamList:function(data){
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html +='<tr>' +

                        '<td class="text-c">' + data[i].mobile + '</td>' +
                        '<td class="text-c">' + data[i].realName + '</td>';
                    if (data[i].isVip == 1) {
                        html += '<td class="text-c">是</td>';
                    } else {
                        html += '<td class="text-c">否</td>';
                    };
                    if (data[i].annualFee == 1) {
                        html += '<td class="text-c">是</td>';
                    } else {
                        html += '<td class="text-c">否</td>';
                    };


                    html += '<td class="text-c">' + data[i].gmtCreate + '</td>';

                    if (data[i].isAuth == 0) {
                        html += '<td class="text-c">未实名</td>';
                    } else {
                        html += '<td class="text-c">已实名</td>';
                    };

                    // html += '<td class="text-c">' +
                    //     '<p><a userId="' + data[i].userId + '" mobile="' + data[i].mobile + '"  class="handle deleteTeam">删除</a></p>' +
                    //     '</td>' +
                    //     '</tr>';
                    html +=
                        '</tr>';
            }
            $('#teamList').html(html);
            $('#teamFoot').css('display', 'table-footer-group');
            _this.getTeamEvent();
        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="6" >暂无数据</td>' +
                '</tr>';
            $('#teamList').html(html);
            $('#teamFoot').css('display', 'none');
        }
    },
    getTeamEvent:function(){
        var _this = this;
        $('.deleteTeam').on('click', function(event) {
            event.preventDefault();
            var mobile=$(this).attr('mobile');
            layui.use('layer', function(){
                layer.confirm('您确定要删除吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    _this.deleteTeam(mobile);
                    layer.close(index);
                }, function(){

                });
            });
        });
    },
    deleteTeam:function(mobile){
        var _this = this;
        var Params = {
            passport: _this.params.passport,
            mobile:mobile

        };
        Api.teammemberslistdelete(Params, function(data) {
            _this.params.page=1;
            _this.getTeamData();

        })
    },
    getReturnData:function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            page: _this.params.returnPage,
            listRows: _this.params.listRows,
            userId:_this.params.userId,
            gmtEnd:_this.params.returngmtEnd,
            gmtStart:_this.params.returngmtStart,
            order:_this.params.order,
            loanSn: _this.params.loanSn,
        };
        console.log(paramsObj);
        Api.billlist(paramsObj, function(data) {
            console.log(data);
             _this.getReturnList(data.list);
            _this.params.returnTotal = data.totalPages;
            layui.use('laypage', function() {
                var laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'returnPage',
                    index: 2,
                    theme: '#3498db',
                    curr: _this.params.returnPage,
                    count: _this.params.returnTotal, //数据总数，从服务端得到
                    hash: 'curr_page',
                    layout: ['prev', 'page', 'next', 'skip'],
                    jump: function(obj, first) {
                        _this.params.returnPage = obj.curr;
                        //obj包含了当前分页的所有参数，比如：curr当前页
                        var Params = {
                            passport: _this.params.passport,
                            page: _this.params.returnPage,
                            listRows: _this.params.listRows,
                            userId:_this.params.userId,
                            gmtEnd:_this.params.returngmtEnd,
                            gmtStart:_this.params.returngmtStart,
                            order:_this.params.order,
                            loanSn: _this.params.loanSn,
                        };
                        Api.billlist(Params, function(data) {
                             _this.getReturnList(data.list);

                        })
                    }
                });
            });
        });
    },
    getReturnList:function(data){
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html +='<tr>' +

                        '<td class="text-c">' + data[i].loanSn + '</td>' +
                        '<td class="text-c">' + data[i].gmtCreate + '</td>'+
                        '<td class="text-c">￥' + data[i].money + '</td>' +
                        '<td class="text-c">' + data[i].batch + '</td>'+
                        '<td class="text-c">' + data[i].unpaidMoney + '</td>';
                    if (data[i].state == 0) {
                        html += '<td class="text-c">未还款</td>';
                    } else if(data[i].state == 1){
                        html += '<td class="text-c">已还款</td>';
                    }else{
                        html += '<td class="text-c">已逾期</td>';
                    };

                    html += '<td class="text-c">' +
                        '<p><a loanId="' + data[i].loanId + '"  class="handle viewReturn">查看订单</a></p>' +
                        '</td>' +
                        '</tr>';
            }
            $('#returnList').html(html);
            $('#returnFoot').css('display', 'table-footer-group');
            _this.getReturnEvent();
        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="7" >暂无数据</td>' +
                '</tr>';
            $('#returnList').html(html);
            $('#returnFoot').css('display', 'none');
        }
    },
    getReturnEvent:function(){
        var _this = this;
        $('.viewReturn').click(function(event) {
            Pub.setSession('loanId', $(this).attr('loanId'));
            window.location.href = Pub.getHtmlUrl('./finance-bill-detail.html');
        });
    },
    getProData:function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            page: _this.params.proPage,
            listRows: _this.params.listRows,
            userId:_this.params.userId,
            gmtEnd:_this.params.progmtEnd,
            gmtStart:_this.params.progmtStart,
            title: _this.params.title,
            order:_this.params.order,
            state:_this.params.state
        };
        console.log(paramsObj);
        Api.newplanlist(paramsObj, function(data) {
            console.log(data);
            _this.getProList(data.list);
            _this.params.proTotal = data.totalPages;
            layui.use('laypage', function() {
                var laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'proPage',
                    index: 3,
                    theme: '#3498db',
                    curr: _this.params.proPage,
                    count: _this.params.proTotal, //数据总数，从服务端得到
                    hash: 'curr_page',
                    layout: ['prev', 'page', 'next', 'skip'],
                    jump: function(obj, first) {
                        _this.params.proPage = obj.curr;
                        //obj包含了当前分页的所有参数，比如：curr当前页
                        var Params = {
                            passport: _this.params.passport,
                            page: _this.params.proPage,
                            listRows: _this.params.listRows,
                            userId:_this.params.userId,
                            gmtEnd:_this.params.progmtEnd,
                            gmtStart:_this.params.progmtStart,
                            title: _this.params.title,
                            order:_this.params.order,
                            state:_this.params.state
                        };
                        Api.newplanlist(Params, function(data) {
                             _this.getProList(data.list);

                        })
                    }
                });
            });
        });
    },
    getProList:function(data){
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html +='<tr>' +
                        '<td class="text-c">' + data[i].planId + '</td>'+
                        '<td class="text-c">' + data[i].title + '</td>';
                if (data[i].state == 2) {
                    html += '<td class="text-c c-danger">未通过</td>';
                } else if (data[i].state == 1) {
                    html += '<td class="text-c">已通过</td>';
                }else if (data[i].state == 0){
                    html += '<td class="text-c">待审核</td>';
                };
                html += '<td class="text-c">' + data[i].gmtCreate + '</td>' +
                        // '<td class="text-c">' + data[i].gmtModified + '</td>' +
                        '<td class="text-c">' +
                            '<p><a planId="' + data[i].planId + '"  class="handle viewPro">查看详情</a></p>' +
                        '</td>' +
                        '</tr>';
            }
            $('#proList').html(html);
            $('#proFoot').css('display', 'table-footer-group');
            _this.getProEvent();
        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="6" >暂无数据</td>' +
                '</tr>';
            $('#proList').html(html);
            $('#proFoot').css('display', 'none');
        }
    },
    getProEvent:function(){
        var _this = this;
        $('.viewPro').click(function(event) {
            Pub.setSession('_isEdit', 1);
            Pub.setSession('planId', $(this).attr('planId'));
            window.location.href = Pub.getHtmlUrl('./plan-list-edit.html');
        });
    },
    paygetData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            page: _this.params.paypage,
            listRows: _this.params.listRows,
            orderNumber:_this.params.orderNumber,
            orderType:_this.params.orderType,
            order:_this.params.order,
            userId:_this.params.userId,
        };
        console.log(paramsObj);
        Api.paymentlist(paramsObj, function(data){
            console.log(data);
            _this.paygetDataList(data.list);
            _this.params.payTotal = data.totalPages;
            layui.use('laypage', function() {
                var laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'payPage',
                    index: 4,
                    theme: '#3498db',
                    curr: _this.params.paypage,
                    count: _this.params.payTotal, //数据总数，从服务端得到
                    hash: 'curr_page',
                    layout: ['prev', 'page', 'next', 'skip'],
                    jump: function(obj, first) {
                        _this.params.paypage = obj.curr;
                        //obj包含了当前分页的所有参数，比如：curr当前页
                        var Params = {
                            passport: _this.params.passport,
                            page: _this.params.paypage,
                            listRows: _this.params.listRows,
                            orderNumber:_this.params.orderNumber,
                            orderType:_this.params.orderType,
                            order:_this.params.order,
                            userId:_this.params.userId,
                        };
                        Api.paymentlist(Params, function(data) {
                            _this.paygetDataList(data.list);

                        })
                    }
                });
            });
        });
    },
    paygetDataList: function(data) {
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html += '<tr>' +

                    '<td class="text-c">' + data[i].orderId + '</td>' +
                    '<td class="text-c">' + data[i].payTitle + '</td>' +
                    '<td class="text-c">￥' + data[i].orderAmount + '</td>';
                if (data[i].orderType=='vip') {
                    html +='<td class="text-c">开通会员</td>';
                }else if(data[i].orderType=='annual'){
                    html +='<td class="text-c">开通年费</td>';
                }else if(data[i].orderType=='consult'){
                    html +='<td class="text-c">资讯费</td>';
                }

                html +='<td class="text-c">' + data[i].gmtCreate + '</td>' +

                    //  '<td class="text-c">' +
                    // '<p><a orderId="' + data[i].orderId + '"  class="handle delete">删除</a></p>' +
                    // '</td>' +
                    '</tr>';
            }
            $('#payList').html(html);
            $('#payFoot').css('display', 'table-footer-group');

        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="5" >暂无数据</td>' +
                '</tr>';
            $('#payList').html(html);
            $('#payFoot').css('display', 'none');
        }
    },
    financegetData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            page: _this.params.fipage,
            listRows: _this.params.listRows,
            withdrawNumber:_this.params.withdrawNumber,
            moneyStart:_this.params.moneyStart,
            moneyEnd:_this.params.moneyEnd,
            state:_this.params.financeState,
            order:_this.params.order,
            userId:_this.params.userId,


        };
        console.log(paramsObj);
        Api.withdrawallist(paramsObj, function(data){
            console.log(data);
            _this.financegetDataList(data.list);
            _this.params.fitotal = data.totalPages;
            layui.use('laypage', function() {
                var laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'fi-Page',
                    index: 5,
                    theme: '#3498db',
                    curr: _this.params.fipage,
                    count: _this.params.fitotal, //数据总数，从服务端得到
                    hash: 'curr_page',
                    layout: ['prev', 'page', 'next', 'skip'],
                    jump: function(obj, first) {
                        _this.params.fipage = obj.curr;
                        //obj包含了当前分页的所有参数，比如：curr当前页
                        var Params = {
                            passport: _this.params.passport,
                            page: _this.params.fipage,
                            listRows: _this.params.listRows,
                            withdrawNumber:_this.params.withdrawNumber,
                            moneyStart:_this.params.moneyStart,
                            moneyEnd:_this.params.moneyEnd,
                            state:_this.params.financeState,
                            order:_this.params.order,
                            userId:_this.params.userId,
                        };
                        Api.withdrawallist(Params, function(data) {
                            _this.financegetDataList(data.list);

                        })
                    }
                });
            });
        });
    },
    financegetDataList: function(data) {
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html += '<tr>' +

                    '<td class="text-c">' + data[i].withdrawNumber + '</td>' +

                    '<td class="text-c">￥' + data[i].money + '</td>';
                if (data[i].state==0) {
                    html+='<td class="text-c">审核中</td>';
                }
                else if (data[i].state==1) {
                    html+='<td class="text-c">借款中</td>';
                }else if(data[i].state==2){
                    html+='<td class="text-c">借款成功</td>';
                }else if(data[i].state==3){
                    html+='<td class="text-c">借款失败</td>';
                }else if(data[i].state==4){
                    html+='<td class="text-c">拒绝</td>';
                };
                // html+='<td class="text-c">' + data[i].gmtCreate + '</td>' +

                //      '<td class="text-c">' +
                //     '<p><a withdrawId="' + data[i].withdrawId + '"  class="handle view">查看</a><a withdrawId="' + data[i].withdrawId + '"  class="handle delete">删除</a></p>' +
                //     '</td>' +
                //     '</tr>';
                html+='<td class="text-c">' + data[i].gmtCreate + '</td>' +
                     '<td class="text-c">' ;
                if (data[i].state==0) {
                    html+='<p><a withdrawId="' + data[i].withdrawId + '"  class="handle fi-audit">审核</a><a withdrawId="' + data[i].withdrawId + '"  class=" fi-view">查看</a></p>';
                }else{
                    html+='<p><a withdrawId="' + data[i].withdrawId + '"  class="fi-view">查看</a></p>';
                };

                    html+='</td>' +
                    '</tr>';
            }
            $('#fi-List').html(html);
            $('#fi-Foot').css('display', 'table-footer-group');
            _this.financegetDataEvent();
        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="5" >暂无数据</td>' +
                '</tr>';
            $('#fi-List').html(html);
            $('#fi-Foot').css('display', 'none');
        }
    },
    financegetDataEvent: function() {
        var _this = this;
        $('.goods-checkbox input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        })
        $('.fi-view').on('click', function() {
            Pub.setSession('withdrawId', $(this).attr('withdrawId'));
            window.location.href = Pub.getHtmlUrl('./finance-withdrawal-deatil.html');
        });
        $('.fi-audit').on('click', function() {
            Pub.setSession('withdrawId', $(this).attr('withdrawId'));
            window.location.href = Pub.getHtmlUrl('./finance-withdrawal-audit.html');
        });
        $('.delete').on('click', function(event) {
            event.preventDefault();
            var withdrawId=$(this).attr('withdrawId');
            layui.use('layer', function(){
                layer.confirm('您确定要删除吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    _this.deleteEvent(withdrawId);
                    layer.close(index);
                }, function(){

                });
            });
        });


    },
    messagegetData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            page: _this.params.messagepage,
            listRows: _this.params.listRows,
            userId:_this.params.userId

        };
        console.log(paramsObj);
        Api.getusermessagelist(paramsObj, function(data){
            console.log(data);
            _this.financegetDataList(data.list);
            _this.params.messagetotal = data.totalPages;
            layui.use('laypage', function() {
                var laypage = layui.laypage;
                //执行一个laypage实例
                laypage.render({
                    elem: 'messagePage',
                    index: 6,
                    theme: '#3498db',
                    curr: _this.params.messagepage,
                    count: _this.params.messagetotal, //数据总数，从服务端得到
                    hash: 'curr_page',
                    layout: ['prev', 'page', 'next', 'skip'],
                    jump: function(obj, first) {
                        _this.params.messagepage = obj.curr;
                        //obj包含了当前分页的所有参数，比如：curr当前页
                        var Params = {
                            passport: _this.params.passport,
                            page: _this.params.messagepage,
                            listRows: _this.params.listRows,
                            userId:_this.params.userId
                        };
                        Api.getusermessagelist(Params, function(data) {
                            _this.messagegetDataList(data.messageList);

                        })
                    }
                });
            });
        });
    },
    messagegetDataList: function(data) {
        var _this = this;
        if (data && data.length > 0) {
            var html = '',
                i = 0,
                len = data.length;
            for (i; i < len; i++) {
                html += '<tr>' +

                    '<td class="text-c">' + data[i].messageId + '</td>' +
                    '<td class="text-c">' + data[i].title + '</td>'+
                    '<td class="text-c">' + data[i].gmtCreate + '</td>' +
                    '<td class="text-c">' +
                        '<p><a messageId="' + data[i].messageId + '"  class="handle mesview">查看详情</a></p>'+
                   '</td>' +
                    '</tr>';
            }
            $('#messageList').html(html);
            $('#messageFoot').css('display', 'table-footer-group');
            _this.messagegetDataEvent();
        } else {
            var html = '<tr>' +
                '<td class="text-c c-666" colspan="4" >暂无数据</td>' +
                '</tr>';
            $('#messageList').html(html);
            $('#messageFoot').css('display', 'none');
        }
    },
    messagegetDataEvent: function() {
        var _this = this;
        $('.mesview').on('click', function() {
            Pub.setSession('messageId', $(this).attr('messageId'));
            window.location.href = Pub.getHtmlUrl('./user-list-detail-message.html');
        });
    },
    otherEvent:function(){
        var _this = this;
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#teamTime',
                range: '~',
                done: function(value, date, endDate) {
                    console.log(date);
                    if (date.year) {
                        if (date.month < 10) {
                            date.month = "0" + date.month;
                        }
                        if (date.date < 10) {
                            date.date = "0" + date.date;
                        }
                        if (endDate.month < 10) {
                            endDate.month = "0" + endDate.month;
                        }
                        if (endDate.date < 10) {
                            endDate.date = "0" + endDate.date;
                        }
                        var gmtStart = date.year + '-' + date.month + '-' + date.date + ' 00:00:00';
                        var gmtEnd = endDate.year + '-' + endDate.month + '-' + endDate.date + ' 00:00:00';
                        _this.params.gmtStart = gmtStart;
                        _this.params.gmtEnd = gmtEnd;

                    } else {
                        _this.params.gmtStart = '';
                        _this.params.gmtEnd = '';
                    };
                }
            });
        });
        $('#isVipSelect').on('change', function(event) {
            event.preventDefault();
            _this.params.isVip=$(this).val();
        });
        $('#vip2Select').on('change', function(event) {
            event.preventDefault();
            _this.params.annualFee = $(this).val();
        });
        $('#teamSearch').click(function(event) {
            _this.params.mobile=$('#teamMobile').val();
            _this.params.page=1;
            _this.getTeamData();
        });
        $('.slectShow').click(function(event) {
            $('.select-wrap').toggle(400);
        });
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#retrunTime',
                range: '~',
                done: function(value, date, endDate) {
                    console.log(date);
                    if (date.year) {
                        if (date.month < 10) {
                            date.month = "0" + date.month;
                        }
                        if (date.date < 10) {
                            date.date = "0" + date.date;
                        }
                        if (endDate.month < 10) {
                            endDate.month = "0" + endDate.month;
                        }
                        if (endDate.date < 10) {
                            endDate.date = "0" + endDate.date;
                        }
                        var gmtStart = date.year + '-' + date.month + '-' + date.date + ' 00:00:00';
                        var gmtEnd = endDate.year + '-' + endDate.month + '-' + endDate.date + ' 00:00:00';
                        _this.params.returngmtStart = gmtStart;
                        _this.params.returngmtEnd = gmtEnd;

                    } else {
                        _this.params.returngmtStart = '';
                        _this.params.returngmtEnd = '';
                    };
                }
            });
        });

        $('.returnShow').click(function(event) {
            $('.return-wrap').toggle(400);
        });
        $('#returnsSearch').click(function(event) {
            _this.params.loanSn=$('#loanSn').val();
            _this.params.returnPage=1;
            _this.getReturnData();
        });
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#proTime',
                range: '~',
                done: function(value, date, endDate) {
                    console.log(date);
                    if (date.year) {
                        if (date.month < 10) {
                            date.month = "0" + date.month;
                        }
                        if (date.date < 10) {
                            date.date = "0" + date.date;
                        }
                        if (endDate.month < 10) {
                            endDate.month = "0" + endDate.month;
                        }
                        if (endDate.date < 10) {
                            endDate.date = "0" + endDate.date;
                        }
                        var gmtStart = date.year + '-' + date.month + '-' + date.date + ' 00:00:00';
                        var gmtEnd = endDate.year + '-' + endDate.month + '-' + endDate.date + ' 00:00:00';
                        _this.params.progmtStart = gmtStart;
                        _this.params.progmtEnd = gmtEnd;

                    } else {
                        _this.params.progmtStart = '';
                        _this.params.progmtEnd = '';
                    };
                }
            });
        });
        $('.proShow').click(function(event) {
            $('.pro-wrap').toggle(400);
        });
        $('#proSearch').click(function(event) {
            _this.params.title=$('#proTitle').val();
            _this.params.proPage=1;
            _this.getProData();
        });
        $('#stateSelect').on('change', function(event) {
            event.preventDefault();
            _this.params.state = $(this).val();
        });
        $('.payShow').click(function(event) {
            $('.pay-wrap').toggle(400);
        });
        $('#paySearch').click(function(event) {
            _this.params.orderNumber=$('#orderNumber').val();
            _this.params.paypage=1;
            _this.paygetData();
        });
        $('#orderTypeSelect').on('change', function(event) {
            event.preventDefault();
            _this.params.orderType = $(this).val();
        });
        $('#isMessage').click(function(event) {
            window.location.href = Pub.getHtmlUrl('./activity-add-user.html');
        });
        $('.fiShow').click(function(event) {
            $('.fi-wrap').toggle(400);
        });
        $('#fi-Search').click(function(event) {
            _this.params.withdrawNumber=$('#withdrawNumber').val();
            _this.params.fipage=1;
            _this.financegetData();
        });
        $('#fi-stateSelect').on('change', function(event) {
            event.preventDefault();
            _this.params.financeState = parseInt($(this).val());

        });
        $('#fi-moneySelect').on('change', function(event) {
            event.preventDefault();
                 _this.params.fipage=1;
               var arr=$(this).val().split("-")
                _this.params.moneyStart=arr[0];
                _this.params.moneyEnd=arr[1];

        });
        $('.breadcrumb-wrap a').css('padding-left', '5px');
        $('.breadcrumb-wrap a').css('padding-right', '5px');


        // 锚点
        // $(".smooth").click(function() {
        //     // $("html,body").animate({scrollTop: }, 1000);
        //     $('.Hui-article').animate({ scrollTop: $($(this).attr('data')).offset().top}, 500);
        //  });

    },
    initEvent: function(){
        var _this = this;
        _this.getData();
        // _this.getReturnData();
        _this.getTeamData();
        _this.getProData();

        _this.paygetData();
        // _this.financegetData();
        _this.messagegetData();
        _this.otherEvent();



    }
};
var page = new Page();